﻿@model LynxWiki.ViewModels.WikiDirectoryViewData

@using LynxWiki.DomainModel;

@{
    ViewBag.Title = "Directory Detail";
}

<h2>Directory Detail</h2>
<p>
    @Html.ActionLink("Create New Directory", "Create")
</p>
<fieldset>
    <legend>WikiDirectoryViewData</legend>

    <span class="label">@Html.DisplayNameFor(model => model.RootDirectory):</span>
        @Html.DisplayFor(model => model.RootDirectory)<br />
    <span class="label">     @Html.DisplayNameFor(model => model.ParentPath):</span>
        @Html.DisplayFor(model => model.ParentPath)<br />
    <span class="label">     @Html.DisplayNameFor(model => model.DirectoryName):</span>
        @Html.DisplayFor(model => model.DirectoryName)<br />
    <span class="label">     @Html.DisplayNameFor(model => model.CreatedOn):</span>
        @Html.DisplayFor(model => model.CreatedOn)<br />
    <span class="label">     @Html.DisplayNameFor(model => model.Creator):</span>
        @Html.DisplayFor(model => model.Creator)<br />
    <span class="label">     @Html.DisplayNameFor(model => model.cntWikiDirs):</span>
        @Html.DisplayFor(model => model.cntWikiDirs)<br />
    <span class="label">     @Html.DisplayNameFor(model => model.cntTopicNames):</span>
        @Html.DisplayFor(model => model.cntTopicNames)<br />
    @if (Server.MapPath(Model.RootDirectory) != Model.ParentPath) {
        <span class="label">Parent Directory:</span>
        int start = Model.ParentPath.IndexOf(Model.RootDirectory);
        string dirUp = Model.ParentPath.Substring(start, Model.ParentPath.Length - (start + Model.DirectoryName.Length + 1));
        @Html.ActionLink(@"~\" + dirUp, "Index", "WikiDirectory", new { fullPath = @"~\" + dirUp }, null)
    }<br />
</fieldset>

    <table class="TableClass">
        <tr>
            <th class="TableCellHighlighted">Directory</th>
            <th class="TableCellHighlighted">Created</th>
            <th class="TableCellHighlighted">Creator</th>
        </tr>
    @foreach (LynxWiki.DomainModel.WikiDirectory wd in Model.WikiDirs) {
        int start = Model.ParentPath.IndexOf(Model.RootDirectory);
        string dirUp = Model.ParentPath.Substring(start, Model.ParentPath.Length - (start + Model.DirectoryName.Length + 1));
        <tr> 
            <td class="TableCell">
                @Html.ActionLink(@"~\" + dirUp + @"\" + Model.DirectoryName + @"\" + wd.DirectoryName, "Index", "WikiDirectory", new { fullPath = @"~\" + dirUp + @"\" + Model.DirectoryName + @"\" + wd.DirectoryName }, null)<br />
            </td>
            <td class="TableCell">@wd.CreatedOn.ToString("yyyy-MM-dd HH:mm:ss")</td>
            <td class="TableCell">@wd.Creator</td>
        </tr>
    }
    </table>

@if (Model.TopicListing != null && Model.TopicListing.Count > 0) {
    <table class="TableClass">
        <tr>
            <th class="TableCellHighlighted">File</th><th class="TableCellHighlighted">Directory</th><th class="TableCellHighlighted">Created On</th>
            @if (User.IsInRole("WikiAdmin")) {
                <th class="TableCellHighlighted">File Actions</th>
            }
        </tr>
        @Html.DisplayFor(m => m.TopicListing)
    </table>
}

